package tech.xs.sys.domain.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import tech.xs.common.framework.domain.entity.TreeEntity;
import tech.xs.common.domain.enums.YesNoEnum;
import tech.xs.common.framework.domain.exception.InvalidParameterException;

import java.util.regex.Matcher;

import static tech.xs.common.util.pattern.CommonPattern.NUMERIC_LETTER_128;

@Getter
@Setter
@ToString
@TableName("sys_web_menu")
public class SysWebMenu extends TreeEntity<SysWebMenu> {

    private String name;

    private String showName;

    private Integer orderValue;

    private String pageUri;

    private YesNoEnum menuStatus;

    private String remark;

    public static void checkCode(String code, String fieldName) {
        Matcher m = NUMERIC_LETTER_128.matcher(code);
        if (!m.matches()) {
            throw new InvalidParameterException(fieldName, "编码只能是大小写字母或数字,最多128个字符");
        }
    }

}
